package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GISFieldType.BOOLEAN;
import static com.magenta.maxoptra.gis.GISFieldType.TEXT;
import static com.magenta.maxoptra.gis.GisParameter.*;
import static com.magenta.maxoptra.gis.MapProviderType.openstreetmap;

/**
 * @author Zaur Muhametgaleev
 * @version 11/18/11 4:49 PM
 * @since Maxoptra 3 (Map providers)
 */
public enum OpenstreetMapAttribute implements GISAccountProperty {
    UseProvider(GisParameter.use_map_provider, MapProviderType.openstreetmap, GISFieldType.BOOLEAN, "false", true, 0L, true),
    OpenstreetMapUrl(base_url, openstreetmap, TEXT, "http://www.openstreetmap.org/openlayers/OpenStreetMap.js", true, 1L, true),
    OpenstreetMapUseCustomGeoAddressForm(use_custom_geo_address_form, openstreetmap, BOOLEAN, "false", true, 2L, true),
    OpenstreetMapUseShortestRoute(use_shortest_route, openstreetmap, GISFieldType.BOOLEAN, "true", false, 3L, true),
    OpenstreetMapEnableLog(enableLogging, openstreetmap, GISFieldType.BOOLEAN, "false", false, 4L, true),
    OpenstreetMapUseMultiplePointsRouting(useMultiplePointsRouting, openstreetmap, GISFieldType.BOOLEAN, "false", false, 5L, true);

    private String name;
    private String label;
    private String tab = "GIS";
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private boolean important = true;

    public boolean isImportant() {
        return important;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public GISFieldType getType() {
        return type;
    }

    @Override
    public String getLabel() {
        return label;
    }

    @Override
    public Long getOrder() {
        return order;
    }

    @Override
    public Boolean getMandatory() {
        return required;
    }

    @Override
    public String getGroup() {
        return groupName;
    }

    @Override
    public String getDefaultValue() {
        return defaultValue;
    }

    public String getTab() {
        return tab;
    }

    private OpenstreetMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                                   boolean required, String groupName, Long order, boolean important) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
    }

    private OpenstreetMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                                   String defaultValue, boolean required, Long order, boolean important) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                providerType.getLabel(),
                order, important);
    }

    public boolean isReadOnly() {
        return false;
    }

}
